<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .title{color:red}
    </style>
</head>
<body>
    <!-- 准备好一个容器 -->
    <div id="test"></div>


    <!-- 引入react核心库 -->
    <script src="../js/16/react.development.js" ></script>
    <!-- 引入react-dom，用于支持react操作DOM -->
    <script src="../js/16/react-dom.development.js"></script>
    <!-- 引入babel，用于将jsx转为js -->
    <script src="../js/babel.js" ></script>
    <script type="text/babel"> /*此处一定要写babel，否则无法识别jsx语法*/
        // 创建类式组件
        class Person extends React.Component{
            render(){
                const { name, age, sex } = this.props
                return (
                    <ul>
                        <li>姓名：{name}</li>    
                        <li>性别：{sex}</li>    
                        <li>年龄：{age}</li>    
                    </ul>
                )
            }
        }
        // 渲染组件到页面
        const p = { name: 'tom', sex: '男', age: 18 }
        // 通过展开运算符批量传递属性
        ReactDOM.render(<Person {...p}/>, document.getElementById('test'))
    </script>
</body>
</html>